/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * Description:
 * Author: huawei
 * Create: 2019-10-15
 */
#ifndef QUEUE_UT
#include <linux/spinlock.h>
#include <linux/slab.h>

#include "queue_module.h"
#include "queue_context.h"
#include "queue_ctx_private.h"

void *queue_context_private_data_create(void)
{
    struct context_private_data *ctx_private = NULL;
    int devid;

    ctx_private = (struct context_private_data *)kmalloc(
        sizeof(struct context_private_data), GFP_ATOMIC | __GFP_ACCOUNT);
    if (ctx_private == NULL) {
        return NULL;
    }

    for (devid = 0; devid < MAX_DEVICE; devid++) {
        ctx_private->hdc_session[devid] = -1;
    }
    INIT_LIST_HEAD(&ctx_private->node_list_head);
    spin_lock_init(&ctx_private->lock);

    return ctx_private;
}

void queue_context_private_data_destroy(void *private_data)
{
    struct context_private_data *ctx_private = (struct context_private_data *)private_data;

    kfree(ctx_private);
    return;
}

#else
void queue_context_host()
{
    return;
}
#endif

